﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace mBlog.Data.Entities
{
    public class Category
    {
        [Key]
        public int Id { get; set; }

        [Column(TypeName = "nvarchar")]
        [Required]
        [StringLength(250)]
        public string Name { get; set; }

        [Column(TypeName = "varchar")]
        [Required]
        [StringLength(250)]
        public string UrlName { get; set; }

        public DateTime AddedTime { get; set; }
        public bool IsActive { get; set; }

        public virtual ICollection<Post> Posts { get; set; }

        public override bool Equals(object obj)
        {
            Category compareTo = obj as Category;
            if (compareTo != null)
            {
                if (this.Id == compareTo.Id || this.UrlName == compareTo.UrlName)
                    return true;
            }
            return base.Equals(obj);
        }
    }
}